package com.zy.stock.quartz;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.zy.stock.crawl.CrawlService;
import com.zy.stock.domain.Stock;
import com.zy.stock.service.StockCrawlRecordService;
import com.zy.stock.service.StockService;

@Component
public class CrawlJob {
	
	private Logger logger = LoggerFactory.getLogger(CrawlJob.class);
	
	@Autowired
	private CrawlService crawlService;
	
	@Autowired
	private StockService stockService;
	
	@Autowired
	private StockCrawlRecordService stockCrawlRecordService;
	
	public void crawl(){
		List<Stock> stocks;
		try {
		    stockCrawlRecordService.ignoreYesterday();
			stocks = stockService.findAll();
			for(Stock stock:stocks){
				crawlService.crawl(stock);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
